package com.java.main.map;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;

/**
 * @author 顾志杰
 * @date 2020/7/24-13:55
 */
public class MapTest {

    public static final Map<String, String> MAP = new ConcurrentHashMap<>();

    public static void main(String[] args) {
//        containcKey();
//        put();

            List<String> strList = new ArrayList<>();
            strList.add("aaa");
            strList.add("bbb");
            strList.add("ccc");

            //数据库查回来的值
            Map<String,Object> map = new HashMap<>();

            strList.forEach(a-> map.putIfAbsent(a,"0"));


    }

    /**
     * 判断指定的key在不在map里
     */
    private static void containcKey() {
        MAP.put("test1", "测试1");
        boolean test1 = MAP.containsKey("test1");
        System.out.println(test1);
    }

    /**
     * map里如果没有的话才put
     */
    private static void put() {
        MAP.putIfAbsent("test02", "测试2");
        System.out.println(MAP);
    }
}
